Skip to main content

Button

1. Write standard firmata to the device

Uploading Standard Firmata to Arduino Open Arduino IDE. File > Examples > Firmata > StandardFirmata.

Tools > Board > your board Tools > Serial Port > your port Click Upload button. if you use WSL, you need to follow this

2. Run the Button

index.tsx
import { Board, Led, Button, render} from "edison"
import React, {useState} from "react"

const App: React.FC = () => {
const [ledOne, setLedOne] = useState(false)

return (
<Board port={'/dev/tty***'} baudRate={57600}>
<Button
pin={8}
triggered={() => setLedOne(true)}
untriggered={() => setLedOne(false)}
>
<Led
pin={13}
isOn={ledOne}
/>
</Button>
</Board>
)
}
render(<App />)

This program will blink the LED when the button is run.

3. execute the program

$ npx vite-node index.tsx 

You can use <Button >

PropsTypeDescriptionDefault
pinnumberPin number to control currentNone
triggered?(() => void)Function executed when a button is pressedNone
untriggered?(() => void)Function executed when the button is releasedNone
debounceTime?numberDelay for a specified period of timeNone
childrenReact.ReactNodeChild components such as outbutNone